<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        function demo(x,...y){  //y为剩余(rest)参数
         //   console.log(x,y);
       //  function demo(...y){ //y为剩余(rest)参数
            console.log(y);
        }

        demo(1,3,9,'ok');


        //函数形参默认值：
        //注意：设置了默认值的形参一定要放在所有形参的最右边


        //定义函数：加、减、乘、除的运算功能
         function test(num1,num2,flag='+') {
        //    function test(num1,flag='+',num2) {
              let result = 0;
             switch(flag){
                  case '+':
                  result = num1+num2;
                  break;
                  case '-':
                  result = num1-num2;
                  break;
                  case '*':
                  result = num1*num2;
                  break;
                  case '/':
                  result = num1/num2;
                  break;                                                      
             }

             return result;
         }

       console.log(test(6,9))  ;
       console.log(test(3,15,'*'))  ;

    </script>
</head>
<body>
    
</body>
</html>